<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="description" content="OTDR">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Snowm">
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>OTDR</title>
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="http://apps.bdimg.com/libs/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<!--[if gte IE 8]><script src="js/lib/jquery/fileupload/cors/jquery.xdr-transport.js"></script><![endif]-->

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>
<body>

	<div class="container1" id="main_container">
		<div class="row">
			<div class="col-sm-12" style="display:none">
				<form id="uploadForm" method="post" action="/rest/sor/parse" enctype="multipart/form-data" class="form-horizontal" style="margin-top:120px;">
					<div class="form-group">
						<div class="col-xs-4 col-sm-12">
							<input id="sor" class="form-control" type="file" name="sor"/>
						</div>
						<div class="col-xs-4 col-sm-12">
							<a id="submit" class="btn btn-success" style="width:100%">解 析</a>
						</div>
					</div>
				</form>
			</div>
			<div class="col-sm-12">
				<form id="uploadForm1" method="post" action="/rest/sor/parse" enctype="multipart/form-data" class="form-horizontal" style="margin-top:120px;">
					<div class="form-group">
						<div class="col-xs-4 col-sm-12">
							<input id="sor1" class="form-control" type="file" name="sor"/>
						</div>
						<div class="col-xs-4 col-sm-12">
							<a id="submit1" class="btn btn-info" style="width:100%" >解 析</a>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
	$("a#submit").click(function() {
		ajaxSubmit();
	});

	$("a#submit1").click(function() {
		submitForm();
	});
	
	function ajaxSubmit() {
		var fileObj = document.getElementById("sor").files[0]; // js 获取文件对象
        if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
            alert("请选择文件");
            return;
        }

        $.ajax({
            url: "/rest/sor/parse",
            data: new FormData($('form#uploadForm')[0]),
            type: "POST",
            //dataType: "json",
            cache: false,//上传文件无需缓存
            processData: false,//用于对data参数进行序列化处理 这里必须false
            contentType: false, //必须
            success: function (result) {
                alert("上传完成!");
            },
        })
	}
	
	function submitForm() {
		$("form#uploadForm1").submit();
	}
});
</script>
</html>